//
//  SLCustomerTestimonialsItemComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/19.
//  
  

#import "SLCustomerTestimonialsItemComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@interface SLCustomerTestimonialsItemComponent ()
@property (nonatomic, strong) UIView *rightView;
@end
@implementation SLCustomerTestimonialsItemComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.layer.borderWidth = 1.5;
        self.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        self.layer.cornerRadius = 15;
        
        [self addSubview:self.titleLabel];
        [self addSubview:self.rightView];
        [self addSubview:self.avatar];
        [self addSubview:self.line];
        [self addSubview:self.nameLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15);
            make.top.equalTo(self).inset(23);
            make.bottom.equalTo(self).inset(23);
        }];
        [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel.mas_right).offset(57);
            make.centerY.equalTo(self);
            make.right.equalTo(self).inset(15);
        }];
        [self.avatar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.rightView).offset(5);
            make.top.equalTo(self.rightView);
            make.width.height.mas_equalTo(45);
            make.right.equalTo(self.rightView);
        }];
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.nameLabel.mas_left).offset(-1);
            make.centerY.equalTo(self.nameLabel);
            make.width.mas_equalTo(38.5);
            make.height.mas_equalTo(1.5);
        }];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.rightView);
            make.top.equalTo(self.avatar.mas_bottom).offset(1);
            make.bottom.equalTo(self.rightView);
        }];
    }
    return self;
}


- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.numberOfLines = 0;
        _titleLabel.text = @"Thanks to this app, I got my loan in just 1 hour! Highly recommended!";
        _titleLabel.font = aspectDefaultFont(14);
        _titleLabel.textColor = UIColorHex(#666666);
    }
    return _titleLabel;
}
- (UIView *)rightView {
    if (!_rightView) {
        _rightView = [UIView new];
    }
    return _rightView;
}
- (UIImageView *)avatar {
    if (!_avatar) {
        _avatar = [UIImageView new];
        _avatar.contentMode = UIViewContentModeScaleAspectFit;
        _avatar.image = [UIImage imageNamed:@"icon_avatar"];
    }
    return _avatar;
}
- (UIView *)line {
    if (!_line) {
        _line = [UIView new];
        _line.backgroundColor = UIColorHex(#666666);
    }
    return _line;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.text = @"Juan, Cebu";
        _nameLabel.textColor = UIColorHex(#666666);
        _nameLabel.font = [UIFont systemFontOfSize:aspectValue(14) weight:700];
    }
    return _nameLabel;
}

@end
